﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WFNetLib;
using System.Net;
using Common;
using WFNetLib.StringFunc;

namespace 联机设备注册
{
    public partial class Form1 : Form
    {
        public string SysConfigFilePath;
        public Form1()
        {
            InitializeComponent();
            SysConfigFilePath = System.Windows.Forms.Application.StartupPath + "\\SysConfig.ini";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                WFHttpWebResponse WebResponse = new WFHttpWebResponse();
                string url;
                url = iniFileOP.Read("Web Set", "WorkAddr", SysConfigFilePath);
                byte[] id = StringsFunction.strToHexByte(maskedTextBox1.Text, " ");
                url = url + "AdminAPI/RegTE.aspx?ID=" + StringsFunction.byteToHexStr(id, "");
                url = url+"&zhuceID="+textBox1.Text;
                HttpWebResponse hr = WebResponse.CreateGetHttpResponse(url);
                RegResult ret = WFJSON.JsonDeserializeBySingleData<RegResult>(WebResponse.Content);
                if(ret.message=="ok")
                    MessageBox.Show("注册成功");
                else
                    MessageBox.Show("注册失败:"+ret.message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
